<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>UnTitle Page</title>
    
    <object  id="readcardCtrl"  classid ="Clsid:8B5A1D0B-4142-4EE1-B247-56DFD7C1CACA" width="184" height="300" ></object>
    <style type="text/css">

        .style10
        {
            height: 35px;
            width: 779px;
        }
        .style32
    {
        width: 755px;
        height: 10px;
        border-collapse: collapse;
        border: 1px solid #c0c0c0;
    }
        .style42
        {
            width: 725px;
            height: 10px;
            border-collapse: collapse;
            border: 1px solid #eeeeee;
        }
        </style>
</head>
<body style="text-align: center">

<script type="text/javascript">
//This example for testing how to use the activex 
//Link the reader
var isComOpen=false;
var icdev;
var state=0;

function Verify(isec,keystr)
{

     var iRel=1;
     state=0;
     var ncard=0;
     
     
     if( icdev <= 0)
         Connect();
     
     ncard=readcardCtrl.findcard(icdev,1);
     if(ncard==0){state=1;alert("Find Card Failed");return;}
     

     iRel=readcardCtrl.loadkey(icdev,0,isec,keystr); 
     if(iRel!=0){state=1;alert("Load key failed.");return;}
     
     iRel=readcardCtrl.authentication(icdev,0,isec);
     if(iRel!=0){state=1;alert("Authenication key failed");return;}
     
}

  function Connect()
{
	var iRet;
	var st;
	try{
	if(isComOpen==false)         //The Reader unlinked
	{
	  var hdev=1;
	  iRet=readcardCtrl.initialcom(100,0);   //Linking reader，if the first parameter values 100, means USB port，
	  if(iRet)
	  {
		icdev=iRet;

		
		var ncard=0;

		st=readcardCtrl.beep(iRet,10);
		
		ncard=readcardCtrl.findcard(iRet,1);
		
		for (i = 1; i <5; i++)
        {

		 st=readcardCtrl.loadkey(iRet,0,i,"ffffffffffff"); 
		 st=readcardCtrl.authentication(iRet,0,i);
		 if(st!=0){alert(i);return;}
		}
        isComOpen=true;             //The Reader Linked
	  }
	  else
	  {
		alert("Line reader failed");
                isComOpen=false;           //Set unlink status of reader 
	  }
	}
	}catch(e){alert(e.message);}
	return;
}
//Write IC card
function Write()
{
    var iRet=1;
    
	
	Verify(1,"ffffffffffff"); 
	if(state>0){alert("Authen 1 failed");return;}
	
	
	iRet = readcardCtrl.directWrite(icdev,4,document.getElementById("DDLPeriodTime").value ); 
	if(iRet!=0){alert("error");return;}
	
	iRet = readcardCtrl.directWrite(icdev,5,document.getElementById("TextName").value ); 
	if(iRet!=0){alert("error");return;}
	iRet = readcardCtrl.directWrite(icdev,6,document.getElementById("DDLLicenseType").value ); 
	

	
	Verify(2,"ffffffffffff");
	if(state>0){alert("Write Card error");return;}

	iRet=readcardCtrl.directWrite(icdev,8,document.getElementById("TextSerialNo").value);
	iRet=readcardCtrl.directWrite(icdev,9,document.getElementById("TextIDcardN").value);
	iRet=readcardCtrl.directWrite(icdev,10,document.getElementById("TextPersonalTelephone").value);
	
	Verify(3,"ffffffffffff");
	if(state>0){alert("Write card error");return;}
	iRet=readcardCtrl.directWrite(icdev,12,document.getElementById("TextXslc").value);
	iRet=readcardCtrl.directWrite(icdev,13,document.getElementById("TextZgcs").value);
	iRet=readcardCtrl.directWrite(icdev,14,document.getElementById("TextMnxs").value);
	
	Verify(4,"ffffffffffff");
	if(state>0){alert("Write card error");return;}
	iRet=readcardCtrl.directWrite(icdev,16,document.getElementById("TextPjcs").value);
	iRet=readcardCtrl.directWrite(icdev,17,document.getElementById("TextLlxs").value);
	iRet=readcardCtrl.directWrite(icdev,18,document.getElementById("TextScxs").value);
	
	if(state == 0)
	{
		alert("Write card OK");
	}

	document.getElementById("TextSerialNo").value="";
	document.getElementById("TextName").value="";
	document.getElementById("TextIDcardN").value="";
	document.getElementById("TextPersonalTelephone").value="";
	document.getElementById("TextXslc").value="";
	document.getElementById("TextPjcs").value="";
	document.getElementById("TextZgcs").value="";
	document.getElementById("TextLlxs").value="";
	document.getElementById("TextMnxs").value="";
	document.getElementById("TextScxs").value="";

	return;
}
//Read Card
function Read()
{

 alert("Read");
 return;

  Verify(1,"ffffffffffff"); 
  if(state>0){alert("Read card error");return;}
  document.getElementById("DDLPeriodTime").value=readcardCtrl.directRead(icdev,4);
  document.getElementById("TextName").value=readcardCtrl.directRead(icdev,5); 
  document.getElementById("DDLLicenseType").value  = readcardCtrl.directRead(icdev,6); 
	
	Verify(2,"ffffffffffff");
	if(state>0){alert("Read card error");return;}
	document.getElementById("TextSerialNo").value=readcardCtrl.directRead(icdev,8);
	document.getElementById("TextIDcardN").value=readcardCtrl.directRead(icdev,9);
	document.getElementById("TextPersonalTelephone").value=readcardCtrl.directRead(icdev,10);
	
	Verify(3,"ffffffffffff");
	if(state>0){alert("Read card error");return;}
	document.getElementById("TextXslc").value=readcardCtrl.directRead(icdev,12);
	document.getElementById("TextZgcs").value=readcardCtrl.directRead(icdev,13);
	document.getElementById("TextMnxs").value=readcardCtrl.directRead(icdev,14);
	
	Verify(4,"ffffffffffff");
	if(state>0){alert("Read card error");return;}
	document.getElementById("TextPjcs").value=readcardCtrl.directRead(icdev,16);
	document.getElementById("TextLlxs").value=readcardCtrl.directRead(icdev,17);
	document.getElementById("TextScxs").value=readcardCtrl.directRead(icdev,18);
}
</script>

    <form id="form1" runat="server">
    <div>
    
        <table class="style10" style="width: 725px">
            <tr>
                <td style="height: 50px; width: 725px; text-align: center; font-family: 楷体_GB2312; font-size: x-large; font-weight: bold;">
                    IC Card Read/Wrie Test With ASP.NET</td>
            </tr>
            <tr>
                <td style="width: 725px;">
                    <table class="style32" style="width: 725px">
                        <tr>
                            <td class="style33" 
                                style="font-family: 黑体; font-size: medium; text-align: right; width: 35px;">
                                <asp:Image ID="ImageUsers" runat="server" ImageUrl="~/Images/IC2_1.jpg" />
                            </td>
                            <td style="font-family: 黑体; font-size: medium; text-align: left; width: 690px;">
                                Write Card/Read Card&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                &nbsp;
                                <asp:Button ID="ButtW_IC" runat="server" Text="Write Card" Width="31px" />
                                <asp:Button ID="ButtR_IC0" runat="server" Text="Read Card"  Width="31px" />
                                <asp:Button ID="ButtInit" runat="server" Text="Clear" Width="33px" />
                            </td>
                        </tr>
                        <tr>
                            <td class="style33" colspan="2" style="width: 725px">
                                <table class="style42" style="width: 725px">
                                    <tr>
                                        <td style="font-family: 宋体; font-size: small; text-align: right; width: 100px; height: 10px">
                                            Shool</td>
                                        <td colspan="3" 
                                            style="font-family: 宋体; font-size: small; text-align: left; height: 10px">
                                            <asp:DropDownList ID="DDLDriveSchool" runat="server" Width="347px">
                                                <asp:ListItem>xxx Driver Shool</asp:ListItem>
                                            </asp:DropDownList>
                                        </td>
                                        <td style="font-family: 宋体; font-size: small; text-align: right; width: 100px; height: 10px">
                                            &nbsp;</td>
                                        <td style="font-family: 宋体; font-size: small; text-align: center; width: 185px; height: 10px">
                                            </td>
                                    </tr>
                                    <tr>
                                        <td style="font-family: 宋体; font-size: small; text-align: right; width: 100px; height: 10px">
                                            In term time</td>
                                        <td style="font-family: 宋体; font-size: small; text-align: left; width: 120px; height: 10px">
                                            <asp:DropDownList ID="DDLPeriodTime" runat="server" AutoPostBack="True" 
                                                Height="16px" Width="124px">
                                                <asp:ListItem>200908</asp:ListItem>
                                                <asp:ListItem>200909</asp:ListItem>
                                                <asp:ListItem>200910</asp:ListItem>
                                                <asp:ListItem>200911</asp:ListItem>
                                                <asp:ListItem>200912</asp:ListItem>
                                            </asp:DropDownList>
                                        </td>
                                        <td style="font-family: 宋体; font-size: small; text-align: right; width: 100px; height: 10px">
                                            SNO</td>
                                        <td style="font-family: 宋体; font-size: small; text-align: left; width: 120px; height: 10px">
                                            <asp:TextBox ID="TextSerialNo" runat="server" Width="117px">200908001</asp:TextBox>
                                        </td>
                                        <td style="font-family: 宋体; font-size: small; text-align: right; width: 100px; height: 10px">
                                            &nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td style="font-family: 宋体; font-size: small; text-align: right; width: 100px; height: 10px">
                                            Name</td>
                                        <td style="font-family: 宋体; font-size: small; text-align: left; width: 120px; height: 10px">
                                            <asp:TextBox ID="TextName"  runat="server" Width="118px">JOHN</asp:TextBox>
                                        </td>
                                        <td style="font-family: 宋体; font-size: small; text-align: right; width: 100px; height: 10px">
                                            Certificate of identification</td>
                                        <td style="font-family: 宋体; font-size: small; text-align: left; width: 120px; height: 10px">
                                            <asp:TextBox ID="TextIDcardN" runat="server" Width="118px">32546765768657</asp:TextBox>
                                        </td>
                                        <td style="font-family: 宋体; font-size: small; text-align: right; width: 100px; height: 10px">
                                            &nbsp;</td>
                                        <td rowspan="6" 
                                            
                                            style="font-family: 宋体; font-size: small; text-align: center; width: 185px; height: 50px; ">
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="font-family: 宋体; font-size: small; text-align: right; width: 110px; height: 10px">
                                            License Type</td>
                                        <td style="font-family: 宋体; font-size: small; text-align: left; width: 120px; height: 10px">
                                            <asp:DropDownList ID="DDLLicenseType" runat="server" Width="125px">
                                                <asp:ListItem>A1</asp:ListItem>
                                                <asp:ListItem>B1</asp:ListItem>
                                                <asp:ListItem>A1B1</asp:ListItem>
                                                <asp:ListItem>A2</asp:ListItem>
                                                <asp:ListItem>A3</asp:ListItem>
                                                <asp:ListItem>B2</asp:ListItem>
                                                <asp:ListItem>C1</asp:ListItem>
                                                <asp:ListItem>C2</asp:ListItem>
                                                <asp:ListItem>C1C2</asp:ListItem>
                                                <asp:ListItem>C3</asp:ListItem>
                                                <asp:ListItem>C4</asp:ListItem>
                                                <asp:ListItem>C3C4</asp:ListItem>
                                                <asp:ListItem>D</asp:ListItem>
                                                <asp:ListItem>E</asp:ListItem>
                                                <asp:ListItem>F</asp:ListItem>
                                                <asp:ListItem>DEF</asp:ListItem>
                                            </asp:DropDownList>
                                        </td>
                                        <td style="font-family: 宋体; font-size: small; text-align: right; width: 100px; height: 10px">
                                            Phone</td>
                                        <td style="font-family: 宋体; font-size: small; text-align: left; width: 120px; height: 10px">
                                            <asp:TextBox ID="TextPersonalTelephone" runat="server" Width="118px">139075583771</asp:TextBox>
                                        </td>
                                        <td rowspan="2" 
                                            style="font-family: 宋体; font-size: small; text-align: center; width: 100px; height: 10px">
                                            &nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td style="font-family: 宋体; font-size: small; text-align: right; width: 100px; height: 10px">
                                            &nbsp;</td>
                                        <td style="font-family: 宋体; font-size: small; text-align: left; width: 120px; height: 10px">
                                            &nbsp;</td>
                                        <td style="font-family: 宋体; font-size: small; text-align: right; width: 100px; height: 10px">
                                            &nbsp;</td>
                                        <td style="font-family: 宋体; font-size: small; text-align: left; width: 120px; height: 10px">
                                            &nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td style="font-family: 宋体; font-size: small; text-align: right; width: 100px; height: 10px">
                                            Actual Service Life</td>
                                        <td style="font-family: 宋体; font-size: small; text-align: left; width: 120px; height: 10px">
                                            <asp:TextBox ID="TextXslc" runat="server" Width="117px">100</asp:TextBox>
                                        </td>
                                        <td style="font-family: 宋体; font-size: small; text-align: right; width: 100px; height: 10px">
                                            Average Speed</td>
                                        <td style="font-family: 宋体; font-size: small; text-align: left; width: 120px; height: 10px">
                                            <asp:TextBox ID="TextPjcs" runat="server" Width="118px">56.8</asp:TextBox>
                                        </td>
                                        <td style="font-family: 宋体; font-size: small; text-align: right; width: 100px; height: 10px">
                                            &nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td style="font-family: 宋体; font-size: small; text-align: right; width: 100px; height: 10px">
                                            MAX Speed</td>
                                        <td style="font-family: 宋体; font-size: small; text-align: left; width: 120px; height: 10px">
                                            <asp:TextBox ID="TextZgcs" runat="server" Width="118px">120.3</asp:TextBox>
                                        </td>
                                        <td style="font-family: 宋体; font-size: small; text-align: right; width: 100px; height: 10px">
                                            Theory Period</td>
                                        <td style="font-family: 宋体; font-size: small; text-align: left; width: 120px; height: 10px">
                                            <asp:TextBox ID="TextLlxs" runat="server" Width="118px">3</asp:TextBox>
                                        </td>
                                        <td style="font-family: 宋体; font-size: small; text-align: center; width: 100px; height: 10px">
                                            &nbsp;</td>
                                    </tr>
                                    <tr>
                                        <td style="font-family: 宋体; font-size: small; text-align: right; width: 100px; height: 10px">
                                            Simulation Period</td>
                                        <td style="font-family: 宋体; font-size: small; text-align: left; width: 120px; height: 10px">
                                            <asp:TextBox ID="TextMnxs" runat="server" Width="118px">2</asp:TextBox>
                                        </td>
                                        <td style="font-family: 宋体; font-size: small; text-align: right; width: 100px; height: 10px">
                                            Practice Period</td>
                                        <td style="font-family: 宋体; font-size: small; text-align: left; width: 120px; height: 10px">
                                            <asp:TextBox ID="TextScxs" runat="server" Width="118px">4</asp:TextBox>
                                        </td>
                                        <td style="font-family: 宋体; font-size: small; text-align: center; width: 100px; height: 10px">
                                            &nbsp;</td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    
    </div>
    </form>
</body>
</html>
